package com.regent.central.bill.service.bean;

import com.regent.central.bill.core.DeliveryAction;
import com.regent.central.bill.repository.DeliveryActionMapper;
import com.regent.central.bill.service.DeliveryActionService;
import com.regent.central.infrastructure.service.bean.DomainServiceBean;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DeliveryActionServiceBean extends DomainServiceBean<DeliveryActionMapper, DeliveryAction> implements DeliveryActionService {
    /**
     * 查找发货单与销售单相关的actionId
     *
     * @param deliveryOrderId
     * @param saleOrderId
     * @return
     */
    @Override
    public List<String> selectGoodsActionIds(String deliveryOrderId, String saleOrderId) {
        return mapper.selectGoodsActionIds(deliveryOrderId, saleOrderId);
    }

    /**
     * 撤销发货单的指定发货货品的关联动作
     *
     * @param deliveryId       发货单
     * @param userCanceled     撤销人
     * @param deliveryGoodsIds 发货货品ID
     */
    @Override
    public void cancel(String deliveryId, String userCanceled, String... deliveryGoodsIds) {
        if (deliveryGoodsIds.length == 0) return;
        mapper.cancel(deliveryId, userCanceled, new Date(), deliveryGoodsIds);
    }
}
